<?php 
class taobaoke_home 
{ 
	function taobaoke_main() 
	{ 
		global $mysql_conn,$v_file;
		$bot_id = $_GET['bot_id'];
		$list_page = $_GET['list_page'];
		$list_num = $_GET['list_num'];
		$sousuokey = $_GET['sousuokey'];
		if (empty($list_page)) $list_page = 1;
		if (empty($list_num)) $list_num = 10;
		if ($list_page < 5) {$list_page0 = 1;} else {$list_page0 = $list_page-4;}
		if ($list_page < 5) {$list_page1 = 1;} else {$list_page1 = $list_page-3;}
		if ($list_page < 5) {$list_page2 = 2;} else {$list_page2 = $list_page-2;}
		if ($list_page < 5) {$list_page3 = 3;} else {$list_page3 = $list_page-1;}
		if ($list_page < 5) {$list_page4 = 4;} else {$list_page4 = $list_page;}
		if ($list_page < 5) {$list_page5 = 5;} else {$list_page5 = $list_page+1;}
		if ($list_page < 5) {$list_page6 = 6;} else {$list_page6 = $list_page+2;}
		if ($list_page < 5) {$list_page7 = 7;} else {$list_page7 = $list_page+3;}
		if ($list_page < 5) {$list_page8 = 8;} else {$list_page8 = $list_page+4;}
		$page_btn .= "<button type='button' class='btn btn-white' onClick='list_page_go(".$list_page0.")'><i class='fa fa-chevron-left'></i></button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page1."' onClick='list_page_go(".$list_page1.")'>".$list_page1."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page2."' onClick='list_page_go(".$list_page2.")'>".$list_page2."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page3."' onClick='list_page_go(".$list_page3.")'>".$list_page3."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page4."' onClick='list_page_go(".$list_page4.")'>".$list_page4."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page5."' onClick='list_page_go(".$list_page5.")'>".$list_page5."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page6."' onClick='list_page_go(".$list_page6.")'>".$list_page6."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page7."' onClick='list_page_go(".$list_page7.")'>".$list_page7."</button>";
		$page_btn .= "<button type='button' class='btn btn-white' onClick='list_page_go(".$list_page8.")'><i class='fa fa-chevron-right'></i></button>";
		$list_limit = ($list_page-1)*$list_num.",".$list_num;
		if (empty($sousuokey)) {
			$sql = "SELECT * from `taobaoke` WHERE `taobaoke_bot` = '".$bot_id."' limit ".$list_limit;
		} else {
			$sql = "SELECT * from `taobaoke` WHERE `taobaoke_bot` = '".$bot_id."' and `taobaoke_key` = '".$sousuokey."'";
		}
		$result = mysql_query($sql,$mysql_conn);
		while(@$row=mysql_fetch_array($result)) {
			$taobaoke_id = $row['taobaoke_id'];
			$taobaoke_key = $row['taobaoke_key'];
			$taobaoke_body = $row['taobaoke_body'];
			$taobaoke_state = $row['taobaoke_state'];
			$taobaokelist .= "<tr><td>";
			$taobaokelist .= "    <input type='checkbox' class='i-checks' name='input[]'>";
			$taobaokelist .= "</td>";
			$taobaokelist .= "<td>".$taobaoke_id."</td>";
			$taobaokelist .= "<td>".$taobaoke_key."</td>";
			$taobaokelist .= "<td>".$taobaoke_body."</td>";
			$taobaokelist .= "<td>";
			$taobaokelist .= "<a href='#' class='btn btn-white btn-xs' onClick='taobaoke_edit(".$taobaoke_id.");'><i class='fa fa-edit'></i> 编辑 </a>";
			$taobaokelist .= "<a href='#' class='btn btn-white btn-xs' onClick='taobaoke_del(".$taobaoke_id.");'><i class='fa fa-trash-o'></i> 删除 </a>";
			$taobaokelist .= "<a href='#' class='btn btn-white btn-xs' onClick='taobaoke_use(".$taobaoke_id.");'><i class='fa fa-trash-o'></i> 对象管理 </a>";
			if ($taobaoke_state == "0") {
				$taobaokelist .= "<a href='#' class='btn btn-white btn-xs' onClick='taobaoke_run(".$taobaoke_id.");'><i class='fa fa-trash-o'></i> 启用 </a>";
			} else if ($taobaoke_state == "1"){
				$taobaokelist .= "<a href='#' class='btn btn-white btn-xs' onClick='taobaoke_stop(".$taobaoke_id.");'><i class='fa fa-trash-o'></i> 禁用 </a>";
			} else {
				$taobaokelist .= "<a href='#' class='btn btn-white btn-xs' ><i class='fa fa-trash-o'></i> 未知 </a>";
			}
			$taobaokelist .= "</td></tr>";
		}
		
							
							
		require($v_file);
	}
	function taobaoke_menu() 
	{ 
		global $mysql_conn,$v_file;
		$bot_id = $_GET['bot_id'];
		$sql = "SELECT * from `taobaoke_id` WHERE `taobaoke_bot` = '".$bot_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		
		if (mysql_num_rows($result) > 0) {
			$taobaoke_pid = $row['taobaoke_pid'];
			$taobaoke_type = $row['taobaoke_type'];
			if (empty($taobaoke_pid)) {
				$taobaoke_menulist .= '<a href="#" class="btn btn-primary btn-xs" onclick="taobaoke_getid();">我的推广 ID ：等待审核</a>';
			} else {
				$taobaoke_menulist .= '<a href="#" class="btn btn-primary btn-xs" onclick="taobaoke_getid();">我的推广 ID ：'.$taobaoke_pid.'</a>';
				if (empty($taobaoke_type)) {
					$taobaoke_menulist .= '<a href="#" class="btn btn-primary btn-xs" >用户等级 ：推广专员</a>';
				} else {
					$taobaoke_menulist .= '<a href="#" class="btn btn-primary btn-xs" >用户等级 ：推广代理</a>';
					$taobaoke_menulist .= '<a href="#" class="btn btn-primary btn-xs" >代理编号 ：'.$taobaoke_type.'</a>';
				}
			}
		} else {
			$taobaoke_menulist .= '<a href="#" class="btn btn-primary btn-xs" onclick="taobaoke_getid();">申请推广 ID</a>';
		}
		$taobaoke_menulist .= '<a href="#" class="btn btn-primary btn-xs" onclick="taobaoke_tongji();">推广报表</a>';
		$user_type = $_COOKIE['user_type'];
		if ($user_type == "1") {
			$taobaoke_menulist .= '<a href="#" class="btn btn-primary btn-xs" onclick="taobaoke_admin();">淘宝客管理</a>';
		}
		echo $taobaoke_menulist;
	}
	function taobaoke_add() 
	{ 
		global $mysql_conn,$v_file;
		$bot_id = $_GET['bot_id'];
		require($v_file);
	}
	function taobaoke_add_do() 
	{ 
		global $mysql_conn;
		$bot_id = $_POST['bot_id'];
		$taobaoke_key = $_POST['taobaoke_key'];
		$taobaoke_body = $_POST['taobaoke_body'];
		$sql = "SELECT * from `taobaoke` WHERE `taobaoke_key` = '".$taobaoke_key."'";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		if (empty($row)) {
			$sql="INSERT INTO taobaoke (taobaoke_id,taobaoke_bot, taobaoke_key, taobaoke_body, taobaoke_state) VALUES (NULL,'$bot_id','$taobaoke_key','$taobaoke_body','0')";
			$result = mysql_query($sql,$mysql_conn);
			@$row = mysql_fetch_array($result);
			echo "2";//规则添加成功
		} else {
			echo  "1";//规则名已存在
		}
	}
	function taobaoke_edit() 
	{ 
		global $mysql_conn,$v_file;
		$taobaoke_id = $_GET['taobaoke_id'];
		$bot_id = $_GET['bot_id'];
		$sql = "SELECT * from `taobaoke` WHERE `taobaoke_id` = '".$taobaoke_id."' and `taobaoke_bot` = '".$bot_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		$taobaoke_key = $row['taobaoke_key'];
		$taobaoke_body = $row['taobaoke_body'];
		require($v_file);
	}
	function taobaoke_edit_do() 
	{ 
		global $mysql_conn;
		$taobaoke_id = $_POST['taobaoke_id'];
		$taobaoke_bot = $_POST['taobaoke_bot'];
		$taobaoke_key = $_POST['taobaoke_key'];
		$taobaoke_body = $_POST['taobaoke_body'];
		$sql = "SELECT * from `taobaoke` WHERE `taobaoke_key` = '".$taobaoke_key."'";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		if (empty($row)) {
			$sql = "UPDATE `taobaoke` SET `taobaoke_key` = '".$taobaoke_key."', `taobaoke_body` = '".$taobaoke_body."' WHERE `taobaoke_id` ='".$taobaoke_id."' and `taobaoke_bot` ='".$taobaoke_bot."';";
			$result = mysql_query($sql,$mysql_conn);
			@$row = mysql_fetch_array($result);
			echo "2";
		} else {
			echo  "1";//规则名已存在
		}
		
	}
	function taobaoke_del_do() 
	{ 
		global $mysql_conn;
		$taobaoke_id = $_POST['taobaoke_id'];
		$sql = "DELETE from `taobaoke` WHERE `taobaoke_id` = '".$taobaoke_id."'";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		echo "2";
	}
	function taobaoke_use() 
	{ 
		global $mysql_conn,$v_file;
		$bot_id = $_GET['bot_id'];
		$sql = "SELECT * from `bot` WHERE `bot_id` = '".$bot_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		$bot_server_id = $row['bot_server_id'];
		$sql = "SELECT * from `server` WHERE `server_id` = '".$bot_server_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		$server_url = $row['server_url'];
		//获取现有的适用对象
		$taobaoke_id = $_GET['taobaoke_id'];
		$sql = "SELECT * from `taobaoke` WHERE `taobaoke_id` = '".$taobaoke_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		$taobaoke_use = $row['taobaoke_use'];
		$taobaoke_use_arr = explode(',',$taobaoke_use); 
		//获取好友数据
		$url = $server_url."openwx/get_friend_info?client=".$bot_id; 
		$html = file_get_contents($url);
		$contact = json_decode($html);
		foreach ($contact as $key=>$value)
		{
			$friend_account = $value->{'account'};
			$friend_name = $value->{'name'};
			$friend_id = $value->{'id'};
			$friend_displayname = $value->{'displayname'};
			$friend_avatar_url = $server_url."openwx/get_avatar?id=".$friend_id."&client=".$bot_id; 
			$friend_category = $value->{'category'};
			if ($friend_category != "公众号") {
				$friend_list.= '<tr><td class="client-avatar"><img alt="image" src="'.$friend_avatar_url.'"> </td>';
				$friend_list.= '<td><a data-toggle="tab" href="weibot_friend.php?m=view?weibot_id='.$bot_id.'&friendid='.$friend_id.'" name="'.$friend_name.'" class="client-link">'.$friend_name.'</a></td>';
				$friend_list.= '<td> '.$friend_displayname.'</td>';
				$friend_list.= '<td class="contact-type"><i class="fa fa-comments"> </i></td>';
				$friend_list.= '<td> '.$friend_account.'</td>';
				if (in_array($friend_displayname, $taobaoke_use_arr)) {
					$friend_list.= '<td class="client-status"><input type="checkbox" name="taobaoke_usename" value="'.$friend_displayname.'" onClick="taobaoke_uselist()" checked> </td></tr>';
				} else {
					$friend_list.= '<td class="client-status"><input type="checkbox" name="taobaoke_usename" value="'.$friend_displayname.'" onClick="taobaoke_uselist()" > </td></tr>';
				}
			}	
		}
		//获取群组数据
		$url = $server_url."openwx/get_group_info?client=".$bot_id;
		$html = file_get_contents($url);
		$contact = json_decode($html);
		foreach ($contact as $key=>$value)
		{
			$group_displayname = $value->{'displayname'};
			$group_id = $value->{'id'};
			$group_member = $value->{'member'};
			$group_member_num = count($group_member);
			$group_avatar_url = $server_url."openwx/get_avatar?id=".$group_id."&client=".$bot_id; 			
			$group_list.= '<tr><td class="client-avatar"><img alt="image" src="'.$group_avatar_url.'"> </td>';
			$group_list.= '<td><a data-toggle="tab" href="weibot_friend.php?m=view$weibot_id='.$client.'&friendid='.$group_id.'" class="client-link">'.$group_displayname.'</a></td>';
			$group_list.= '<td></td><td class="contact-type"><i class="fa fa-comments"> </i></td>';
			$group_list.= '<td>成员：'.$group_member_num.' 人</td>';
			if (in_array($group_displayname, $taobaoke_use_arr)) {
					$group_list.= '<td class="client-status"><input type="checkbox" name="taobaoke_usename" value="'.$group_displayname.'"  onClick="taobaoke_uselist()" checked> </td></tr>';		
				} else {
					$group_list.= '<td class="client-status"><input type="checkbox" name="taobaoke_usename" value="'.$group_displayname.'"  onClick="taobaoke_uselist()" > </td></tr>';		
				}
		}
		require($v_file);
	}
	function taobaoke_use_do() 
	{
		global $mysql_conn,$v_file;
		$taobaoke_id = $_POST['taobaoke_id'];
		$taobaoke_use = $_POST['taobaoke_use'];
		$sql = "UPDATE `taobaoke` SET `taobaoke_use` = '".$taobaoke_use."' WHERE `taobaoke_id` ='".$taobaoke_id."' ;";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		echo "2";
	}
	function taobaoke_getid() 
	{
		global $mysql_conn,$v_file;
		$bot_id = $_GET['bot_id'];
		require($v_file);
	}
	function taobaoke_getid_do() 
	{
		global $mysql_conn,$v_file;
		$bot_id = $_POST['bot_id'];
		$taobaoke_getid_from = $_POST['taobaoke_getid_from'];
		$taobaoke_getid_beizhu = $_POST['taobaoke_getid_beizhu'];
		if (empty($taobaoke_getid_from)) {
			$sql = "SELECT * from `taobaoke_set` limit 0,1";
			$result = mysql_query($sql,$mysql_conn);
			@$row = mysql_fetch_array($result);
			$taobaoke_pidmain = $row['taobaoke_pidmain'];
			$taobaoke_getid_from = $taobaoke_pidmain;
			$sql = "SELECT * from `taobaoke_pid` WHERE `taobaoke_form` = '".$taobaoke_getid_from."' and `taobaoke_type` = '0' limit 0,1";
			$result = mysql_query($sql,$mysql_conn);
			@$row = mysql_fetch_array($result);
			$taobaoke_pid = $row['taobaoke_pid'];
			$sql = "SELECT * from `taobaoke_id` WHERE `taobaoke_bot` = '".$bot_id."'";
			$result = mysql_query($sql,$mysql_conn);
			@$row = mysql_fetch_array($result);
			if (empty($row)) {
				$sql="INSERT INTO taobaoke_id (taobaoke_id, taobaoke_bot, taobaoke_pid, taobaoke_type, taobaoke_form, taobaoke_beizhu) VALUES (NULL,'$bot_id','$taobaoke_pid',NULL,'$taobaoke_getid_from','$taobaoke_getid_beizhu')";
				$result = mysql_query($sql,$mysql_conn);
				@$row = mysql_fetch_array($result);
				$sql = "UPDATE `taobaoke_pid` SET `taobaoke_type` = '1' WHERE `taobaoke_pid` ='".$taobaoke_pid."' and `taobaoke_form` ='".$taobaoke_getid_from."' ;";
				$result = mysql_query($sql,$mysql_conn);
				@$row = mysql_fetch_array($result);
				echo "3";//申请添加成功
			} else {
				echo  "2";//申请已存在
			}
		} else {
			$sql = "SELECT * from `taobaoke_pid` WHERE `taobaoke_form` = '".$taobaoke_getid_from."'";
			$result = mysql_query($sql,$mysql_conn);
			@$row = mysql_fetch_array($result);
			if (empty($row)) {
				echo "1";//填写的渠道不存在，邀请码没管用
			} else {
				$sql = "SELECT * from `taobaoke_pid` WHERE `taobaoke_form` = '".$taobaoke_getid_from."' and `taobaoke_type` = '0' limit 0,1";
				$result = mysql_query($sql,$mysql_conn);
				@$row = mysql_fetch_array($result);
				$taobaoke_pid = $row['taobaoke_pid'];
				$sql = "SELECT * from `taobaoke_id` WHERE `taobaoke_bot` = '".$bot_id."'";
				$result = mysql_query($sql,$mysql_conn);
				@$row = mysql_fetch_array($result);
				if (empty($row)) {
					$sql="INSERT INTO taobaoke_id (taobaoke_id, taobaoke_bot, taobaoke_pid, taobaoke_type, taobaoke_form, taobaoke_beizhu) VALUES (NULL,'$bot_id','$taobaoke_pid',NULL,'$taobaoke_getid_from','$taobaoke_getid_beizhu')";
					$result = mysql_query($sql,$mysql_conn);
					@$row = mysql_fetch_array($result);
					$sql = "UPDATE `taobaoke_pid` SET `taobaoke_type` = '1' WHERE `taobaoke_pid` ='".$taobaoke_pid."' and `taobaoke_form` ='".$taobaoke_getid_from."' ;";
					$result = mysql_query($sql,$mysql_conn);
					@$row = mysql_fetch_array($result);
					echo "3";//申请添加成功
				} else {
					echo  "2";//申请已存在
				}
			}
		}

	}
	function taobaoke_admin() 
	{ 
		global $mysql_conn,$v_file;
		$bot_id = $_GET['bot_id'];
		$list_page = $_GET['list_page'];
		$list_num = $_GET['list_num'];
		$sousuokey = $_GET['sousuokey'];
		if (empty($list_page)) $list_page = 1;
		if (empty($list_num)) $list_num = 10;
		if ($list_page < 5) {$list_page0 = 1;} else {$list_page0 = $list_page-4;}
		if ($list_page < 5) {$list_page1 = 1;} else {$list_page1 = $list_page-3;}
		if ($list_page < 5) {$list_page2 = 2;} else {$list_page2 = $list_page-2;}
		if ($list_page < 5) {$list_page3 = 3;} else {$list_page3 = $list_page-1;}
		if ($list_page < 5) {$list_page4 = 4;} else {$list_page4 = $list_page;}
		if ($list_page < 5) {$list_page5 = 5;} else {$list_page5 = $list_page+1;}
		if ($list_page < 5) {$list_page6 = 6;} else {$list_page6 = $list_page+2;}
		if ($list_page < 5) {$list_page7 = 7;} else {$list_page7 = $list_page+3;}
		if ($list_page < 5) {$list_page8 = 8;} else {$list_page8 = $list_page+4;}
		$page_btn .= "<button type='button' class='btn btn-white' onClick='list_page_go(".$list_page0.")'><i class='fa fa-chevron-left'></i></button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page1."' onClick='list_page_go(".$list_page1.")'>".$list_page1."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page2."' onClick='list_page_go(".$list_page2.")'>".$list_page2."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page3."' onClick='list_page_go(".$list_page3.")'>".$list_page3."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page4."' onClick='list_page_go(".$list_page4.")'>".$list_page4."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page5."' onClick='list_page_go(".$list_page5.")'>".$list_page5."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page6."' onClick='list_page_go(".$list_page6.")'>".$list_page6."</button>";
		$page_btn .= "<button class='btn btn-white' id='list_page".$list_page7."' onClick='list_page_go(".$list_page7.")'>".$list_page7."</button>";
		$page_btn .= "<button type='button' class='btn btn-white' onClick='list_page_go(".$list_page8.")'><i class='fa fa-chevron-right'></i></button>";
		$list_limit = ($list_page-1)*$list_num.",".$list_num;
		if (empty($sousuokey)) {
			$sql = "SELECT * from `taobaoke_id` limit ".$list_limit;
		} else {
			$sql = "SELECT * from `taobaoke_id` WHERE `taobaoke_pid` = '".$sousuokey."'";
		}
		$result = mysql_query($sql,$mysql_conn);
		while(@$row=mysql_fetch_array($result)) {
			$taobaoke_id = $row['taobaoke_id'];
			$taobaoke_bot = $row['taobaoke_bot'];
			$taobaoke_pid = $row['taobaoke_pid'];
			$taobaoke_type = $row['taobaoke_type'];
			$taobaoke_form = $row['taobaoke_form'];
			$taobaoke_beizhu = $row['taobaoke_beizhu'];
			$taobaokelist .= "<tr><td>";
			$taobaokelist .= "    <input type='checkbox' class='i-checks' name='input[]'>";
			$taobaokelist .= "</td>";
			$taobaokelist .= "<td>".$taobaoke_id."</td>";
			$taobaokelist .= "<td>".$taobaoke_bot."</td>";
			$taobaokelist .= "<td>".$taobaoke_pid."</td>";
			$taobaokelist .= "<td>".$taobaoke_type."</td>";
			$taobaokelist .= "<td>".$taobaoke_form."</td>";
			$taobaokelist .= "<td>".$taobaoke_beizhu."</td>";
			$taobaokelist .= "<td>";
			$taobaokelist .= "<a href='#' class='btn btn-white btn-xs' onClick='taobaoke_adminedit(".$taobaoke_id.");'><i class='fa fa-edit'></i> 编辑 </a>";
			$taobaokelist .= "<a href='#' class='btn btn-white btn-xs' onClick='taobaoke_admindel(".$taobaoke_id.");'><i class='fa fa-trash-o'></i> 删除 </a>";
			$taobaokelist .= "</td></tr>";
		}				
		require($v_file);
	}
	function taobaoke_adminset() 
	{ 
		global $mysql_conn,$v_file;
		$sql = "SELECT * from `taobaoke_set` ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		$taobaoke_id = $row['taobaoke_id'];
		$taobaoke_host = $row['taobaoke_host'];
		$taobaoke_name = $row['taobaoke_name'];
		$taobaoke_password = $row['taobaoke_password'];
		$taobaoke_data = $row['taobaoke_data'];
		$taobaoke_table = $row['taobaoke_table'];
		$taobaoke_pid = $row['taobaoke_pid'];
		$taobaoke_pidmain = $row['taobaoke_pidmain'];
		require($v_file);
	}
	function taobaoke_adminset_do() 
	{ 
		global $mysql_conn;
		$taobaoke_id = $_POST['taobaoke_id'];
		$taobaoke_host = $_POST['taobaoke_host'];
		$taobaoke_name = $_POST['taobaoke_name'];
		$taobaoke_password = $_POST['taobaoke_password'];
		$taobaoke_data = $_POST['taobaoke_data'];
		$taobaoke_table = $_POST['taobaoke_table'];
		$taobaoke_pid = $_POST['taobaoke_pid'];
		$taobaoke_pidmain = $_POST['taobaoke_pidmain'];
		$sql = "UPDATE `taobaoke_set` SET `taobaoke_host` = '".$taobaoke_host."', `taobaoke_name` = '".$taobaoke_name."', `taobaoke_password` = '".$taobaoke_password."', `taobaoke_data` = '".$taobaoke_data."', `taobaoke_table` = '".$taobaoke_table."', `taobaoke_pid` = '".$taobaoke_pid."', `taobaoke_pidmain` = '".$taobaoke_pidmain."' WHERE `taobaoke_id` ='".$taobaoke_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		echo "2";
	}
	function taobaoke_adminedit() 
	{ 
		global $mysql_conn,$v_file;
		$taobaoke_id = $_GET['taobaoke_id'];
		$bot_id = $_GET['bot_id'];
		$sql = "SELECT * from `taobaoke_id` WHERE `taobaoke_id` = '".$taobaoke_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		$taobaoke_id = $row['taobaoke_id'];
		$taobaoke_bot = $row['taobaoke_bot'];
		$taobaoke_pid = $row['taobaoke_pid'];
		$taobaoke_type = $row['taobaoke_type'];
		$taobaoke_form = $row['taobaoke_form'];
		$taobaoke_beizhu = $row['taobaoke_beizhu'];
		require($v_file);
	}
	function taobaoke_adminedit_do() 
	{ 
		global $mysql_conn;
		$taobaoke_id = $_POST['taobaoke_id'];
		$taobaoke_bot = $_POST['taobaoke_bot'];
		$taobaoke_pid = $_POST['taobaoke_pid'];
		$taobaoke_type = $_POST['taobaoke_type'];
		$taobaoke_form = $_POST['taobaoke_form'];
		$taobaoke_beizhu = $_POST['taobaoke_beizhu'];
		$sql = "UPDATE `taobaoke_id` SET `taobaoke_pid` = '".$taobaoke_pid."', `taobaoke_type` = '".$taobaoke_type."', `taobaoke_form` = '".$taobaoke_form."', `taobaoke_beizhu` = '".$taobaoke_beizhu."' WHERE `taobaoke_id` ='".$taobaoke_id."' and `taobaoke_bot` ='".$taobaoke_bot."';";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		echo "2";
	}
	function taobaoke_admindel_do() 
	{ 
		global $mysql_conn;
		$taobaoke_id = $_POST['taobaoke_id'];
		$sql = "DELETE from `taobaoke_id` WHERE `taobaoke_id` = '".$taobaoke_id."'";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		echo "2";
	}
	function taobaoke_run() 
	{ 
		global $mysql_conn;
		$taobaoke_id = $_POST['taobaoke_id'];
		$sql = "UPDATE `taobaoke` SET `taobaoke_state` = '1' WHERE `taobaoke_id` ='".$taobaoke_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		echo "2";
	}
	function taobaoke_stop() 
	{ 
		global $mysql_conn;
		$taobaoke_id = $_POST['taobaoke_id'];
		$sql = "UPDATE `taobaoke` SET `taobaoke_state` = '0' WHERE `taobaoke_id` ='".$taobaoke_id."' ";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		echo "2";
	}
} 
/* End of file democontroller.php */ 